<!--
// +----------------------------------------------------------------------
// | Created by PHPstorm: JRKAdmin框架 [ JRKAdmin ]
// +----------------------------------------------------------------------
// | Copyright (c) 2019~2022 [LuckyHHY] All rights reserved.
// +----------------------------------------------------------------------
// | SiteUrl: http://www.luckyhhy.cn
// +----------------------------------------------------------------------
// | Author: LuckyHhy <jackhhy520@qq.com>
// +----------------------------------------------------------------------
// | Date: 2020/3/4-14:23
// +----------------------------------------------------------------------
// | Description:
// +----------------------------------------------------------------------
*-->


{extend name='public/window' /}


{block name="content"}

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form">
                <div class="layui-tab layui-tab-card">
                    <ul class="layui-tab-title">
                        <li class="layui-this">基本选项</li>
                        <li>模板设置</li>
                    </ul>
                    <div class="layui-tab-content" style="min-height: 780px">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">选择模型</label>
                                <div class="layui-input-inline input-custom-width">
                                    <select name="model_id" lay-verify="required" lay-filter="model_select">
                                        <option value="0">请选择模型</option>
                                        {foreach name="model_select" id="model"}
                                        <option value="{$model['id']}" {if condition='$model["id"] eq $info["model_id"]'}selected{/if}>{$model.name}</option>
                                        {/foreach}
                                    </select>

                                </div>
                                <div class="layui-form-mid layui-word-aux">模型创建后不可修改</div>
                            </div>

                            {:token()}

                            <div class="layui-form-item">
                                <label class="layui-form-label">上级栏目</label>
                                <div class="layui-input-block input-custom-width select-pid">
                                    {:widget('common/forms/singleSelect',array('pid|2|上级栏目|title_show|id',$tree,$info['pid']))}
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">栏目名称</label>
                                <div class="layui-input-block input-custom-width">
                                    <input type="text" name="name"  lay-verify="required" value="{$info.name}" placeholder="请输入栏目名称"  lay-vertype="tips" lay-reqtext="请输入栏目名称" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <input type="hidden" name="id"   class="layui-input" value="{$info.id}">

                            <div class="layui-form-item category_url" {if condition="$info['model_id'] neq '4'"}style="display: none"{/if} >
                                <label class="layui-form-label">外部链接</label>
                                <div class="layui-input-inline input-custom-width">
                                    <input type="text" name="url" placeholder="请输入外部链接" value="{$info.url}" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">链接需http://或https://开头</div>
                            </div>

                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">栏目描述</label>
                                <div class="layui-input-block input-custom-width">
                                    <textarea name="description" placeholder="请输入栏目描述" class="layui-textarea">{$info.description}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">排序</label>
                                <div class="layui-input-inline input-custom-width">
                                    <input type="number" name="sort" required autocomplete="off" class="layui-input" value="{$info.sort}">
                                </div>
                                <div class="layui-form-mid layui-word-aux">值越大越靠前</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">是否显示</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="is_show" value="1" title="是" {eq name="$info.is_show" value="1"} checked {/eq} >
                                    <input type="radio" name="is_show" value="0" title="否" {eq name="$info.is_show" value="0"} checked {/eq}>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="layui-form-item">
                                <label class="layui-form-label">封面页模版</label>
                                <div class="layui-input-block input-custom-width">
                                    <input type="text" name="index_template"  placeholder="请输入封面页模版" autocomplete="off" class="layui-input" value="{$info.index_template|default='index'}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">列表页模版</label>
                                <div class="layui-input-block input-custom-width">
                                    <input type="text" name="list_template"  placeholder="请输入列表页模版" autocomplete="off" class="layui-input" value="{$info.index_template|default='lists'}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">详情页模版</label>
                                <div class="layui-input-block input-custom-width">
                                    <input type="text" name="show_template"  placeholder="请输入详情页模版" autocomplete="off" class="layui-input" value="{$info.index_template|default='show'}">
                                </div>
                            </div>

                        </div>

                    </div>
                </div>

        
                {:widget('common/forms/submit',array('add','立即提交',2))}


            </form>


        </div>
    </div>
</div>



<script>
    layui.use(['element', 'form', 'jquery','lucky'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
        var lucky=layui.lucky;



        //模型选择监听
        form.on('select(model_select)',function (data) {
            if (data.value == 4){
                $(".category_url").show();
                $(".category_url input[name=url]").attr('required','required');
                $(".category_url input[name=url]").attr('lay-verify','required');
            }else{
                $(".category_url").hide();
                $(".category_url input[name=url]").removeAttr('required');
                $(".category_url input[name=url]").removeAttr('lay-verify');
            }
        });

        form.on('submit(add)', function (data) {
            lucky.FormSubmit("{:url('category/addCategory')}",data.field,"tableFilter",1);
            return false;
        });
    })
</script>

{/block}

